-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(issues): infer project platform if not set #95402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #95402 +/- ##
==========================================
- Coverage 87.84% 82.88% -4.97%
==========================================
Files 10502 10457 -45
Lines 608126 605810 -2316
Branches 23719 23710 -9
==========================================
- Hits 534228 502133 -32095
- Misses 73540 103319 +29779
Partials 358 358 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good :), just a minor comment about a comment, might want to let Katie approve as well before you merge
src/sentry/event_manager.py
Outdated
def _set_project_platform_if_needed(project: Project, event: Event) -> None: | ||
# Only infer the platform if it's useful - if the event platform is "other" or null, there's | ||
# no useful information for us to set the project platform | ||
if not event.platform or event.platform == "other": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here, we exclude events without a platform - we won't overwrite platform
if it is set anywhere
the motivation to exclude 'other' events is that in cases where an event is missing a platform, it seems to get normalized to 'other'. in those cases, i'd rather ignore the event and do nothing rather than assign the project to 'other'
76d0cda
to
054c0b2
Compare
if project.platform: | ||
return | ||
|
||
if event.platform not in VALID_PLATFORMS or event.get_tag("sample_event") == "yes": | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Could combine this into the same if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: In-memory Project Platform Not Updated Post-Database Write
When a project's platform is inferred and updated in the database, the in-memory project
object's platform
attribute is not refreshed. This results in stale project.platform
data (None or empty string) for subsequent operations within the same request, even though the database has been correctly updated. The fix involves updating the in-memory project.platform
attribute after the successful database write.
src/sentry/event_manager.py#L709-L720
sentry/src/sentry/event_manager.py
Lines 709 to 720 in 6f7ee89
try: | |
updated = Project.objects.filter( | |
Q(id=project.id) & (Q(platform__isnull=True) | Q(platform="")) | |
).update(platform=event.platform) | |
if updated: | |
create_system_audit_entry( | |
organization=project.organization, | |
target_object=project.id, | |
event=audit_log.get_event_id("PROJECT_EDIT"), | |
data={**project.get_audit_log_data(), "platform": event.platform}, | |
) |
Was this report helpful? Give feedback by reacting with 👍 or 👎
If a project ends up with no
platform
(e.g. by API creation), we attempt to infer it from its next event by setting the project'splatform
to the event'splatform
.Related: